﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SchEdu.Framework.Exceptions;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Validators;

namespace SchEdu.Framework.Constraint
{
    class FinishDateConstraint : Constraint
    {
        public FinishDateConstraint()
        {
        }
        public FinishDateConstraint(SchEduData schEduData, SchEduDataSet.AllocationRow allocation)
            : base(schEduData, allocation)
        {
        }

        public override void Logic()
        {
            if (Allocation.OrderRow.FinishDate < Allocation.EndDate)
            {
                GenerateConstraintRow();
                constraint.Message = Resources.AllocationViolateFinishDate;
            }
        }

        protected override void InitializeValidators()
        {
            base.InitializeValidators();
            validators.Add(new OrderFinishDateValidator(SchEduData));
        }

        public override AboutInfo AboutInfo
        {
            get
            {
                AboutInfo aboutInfo = new AboutInfo();
                aboutInfo.Title = "Finish Date Constraint";
                aboutInfo.Guid = new Guid("{813D77EE-6001-4b77-B474-7D9631608E09}");
                aboutInfo.Description = Resources.FinishDateConstraintDescription;
                return aboutInfo;
            }
        }

    }
}
